import { Component } from 'react'
class List extends Component {

    constructor() {
        super()
        this.state = {
            list: [
                {
                    "id": 1165,
                    "name": "小白",
                },
                {
                    "id": 1162,
                    "name": "小兰",
                },
                {
                    "id": 1161,
                    "name": "小黑"
                }
            ]
        }
    }
    edit=(id)=>{

        return ()=>{
            alert(id);
        }

    }
    render() {
        return (
            <div className='list'>列表

            <div>
                <ul>
                 {
                    this.state.list.map((item,index)=>(

                        <li key={item.id}>{index}、{item.name}
                        
                        <button onClick={this.edit(item.id)}>修改</button>
                        </li>
                    ))
                 }
                 </ul>
            </div>
            
            </div>
        )
    }

}
export default List;